package com.wbl.network

import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory

object HttpService {
    fun <T> create(clazz: Class<T>): T {
        return Retrofit.Builder()
            .baseUrl("https://www.wanandroid.com")
            .client(okhttpClient())
            .addConverterFactory(GsonConverterFactory.create())
            .build()
            .create(clazz)
    }

    fun okhttpClient(): OkHttpClient =
        OkHttpClient.Builder()
            .addInterceptor(CookieInterceptor())
            .addInterceptor(HttpLoggingInterceptor())
            .build()
}